<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <font color="white">
        <?php
            $cart = array();
            $total = 0;
            $k=0;
                        
            $connec=mysql_connect("localhost","root");
            mysql_select_db("shoppingcart",$connec);

             echo "</br>";
             echo "</br>";
             echo "</br>";
             echo "</br>";
             echo "</br>";

             if(count($_SESSION["cart"])!=0){

                   echo "<table border=\"1\" align=\"center\">";
                   echo "<thead>
                        <tr>
                        <th>NAME</th>
                        <th>CATEGORY</th>
                        <th>PRICE</th>
                        <th>QUANTITY</th>
                        <th>TOTAL</th>
                        <th>DROP</th>
                        </tr>
                        </thead>
                        <tbody>";
                  

                  foreach ($_SESSION["cart"] as $name)
                    {
                             
                        $result1=mysql_query("SELECT * FROM products",$connec);

                        while ($row1=mysql_fetch_array($result1))
                        {
                                      
                            if ($row1["id"]==$name)
                                {
                                $cart[] = $row1["name"];
                                $total += $_SESSION["quantity"][$k]*$row1["price"];

                                //NOW PRINTING THE ENTRIES IN TABLE FORMAT

                                echo "<tr>";
                                echo "<td>".$row1["name"]."</td>";
                                echo "<td>".$row1["category"]."</td>";
                                echo "<td>".$row1["price"]."</td>";
                                echo "<td>".$_SESSION["quantity"][$k]."</td>";
                                echo "<td>".$row1["price"]*$_SESSION["quantity"][$k]."</td>";
                                echo "<td> <a href=\"index.php?drop=".$row1["id"]."\"> <img src=\"images/Drop.jpg\" width=\"40\" height=\"40\"> </a> </td>";
                                echo "</tr>";
                        
                                break;
                                }
                        }
                        $k+=1;
                    }
                    echo "</tbody>
                          </table>";

                    echo "</br>";
                    echo "</br>";
                    echo "</br>";
                    echo "</br>";
                    echo "</br>";
                    echo "Total shopping cost including shipping =Rs.".($total+100);
                    mysql_close($connec);

                    echo "</br>
                    </br>
                    </br>
                    </br>";
            
                    echo "<form action=\"index.php\" method=\"post\">";
                    echo "<div>";
                    echo "<input type=\"hidden\" name=\"id\" value=1/>";
                    echo "  <input type=\"submit\" name=\"action\" value=\"Empty Cart\"/>   ";
                    echo "</div>";
                    echo "</form>";

                    echo "</br>
                    </br>
                    </br>
                    </br>";

                    echo "<form action=\"index.php\" method=\"post\">";
                    echo "<div>";
                    echo "<input type=\"hidden\" name=\"id\" value=1/>";
                    echo "  <input type=\"submit\" name=\"action\" value=\"Checkout\"/>   ";
                    echo "</div>";
                    echo "</form>";
            }

        ?>
        </font>
    </body>
</html>
